#include "mainwindow.h"
#include <QHBoxLayout>
#include "SingleAI.h"
#include "MaxMinAI.h"
#include "NegaMaxAI.h"
#include "AlphaBetaAI.h"
#include "netgame.h"
#include "ctrlpanel.h"

MainWindow::MainWindow(int gameType, QWidget *parent) : QWidget(parent)
{
    QHBoxLayout* hLay = new QHBoxLayout(this);
    CtrlPanel* ctrlPanel = new CtrlPanel;
    if (gameType == 0) {
        SingleAI *ai = new SingleAI();
        hLay->addWidget(ai, 1);
        connect(ctrlPanel, SIGNAL(sigBack()), ai, SLOT(slotBack()));
    } else if (gameType == 1) {
        MaxMinAI *ai = new MaxMinAI();
        hLay->addWidget(ai, 1);
        connect(ctrlPanel, SIGNAL(sigBack()), ai, SLOT(slotBack()));
    } else if (gameType == 2) {
        NegaMaxAI *ai = new NegaMaxAI();
        hLay->addWidget(ai, 1);
        connect(ctrlPanel, SIGNAL(sigBack()), ai, SLOT(slotBack()));
    } else if (gameType == 3) {
        AlphaBetaAI *ai = new AlphaBetaAI();
        hLay->addWidget(ai, 1);
        connect(ctrlPanel, SIGNAL(sigBack()), ai, SLOT(slotBack()));
    } else if (gameType == 4) {
        Board *board = new Board();
        hLay->addWidget(board, 1);
        connect(ctrlPanel, SIGNAL(sigBack()), board, SLOT(slotBack()));
    } else if (gameType == 5) {
        NetGame *server = new NetGame(true);
        hLay->addWidget(server, 1);
        connect(ctrlPanel, SIGNAL(sigBack()), server, SLOT(slotBack()));
    } else if (gameType == 6) {
        NetGame *socket = new NetGame(false);
        hLay->addWidget(socket, 1);
        connect(ctrlPanel, SIGNAL(sigBack()), socket, SLOT(slotBack()));
    }
    hLay->addWidget(ctrlPanel);
}

